package com.itheima.day07;

import com.sun.source.tree.Tree;

import java.util.HashMap;
import java.util.TreeMap;

public class Practice2 {
    public static void main(String[] args) {
      TreeMap<Student1,String> tree  = new TreeMap<>();
      tree.put(new Student1("张三",20,165),"上海");
      tree.put(new Student1("张四",16,168.5),"上海");
      tree.put(new Student1("张五",18,165.5),"上海");
      tree.put(new Student1("张六",25,175),"上海");
         tree.forEach((k,v)-> System.out.println(k+"->"+v));
    }
}
class Student1 implements Comparable<Student1>{
    private String name;
    private  int age ;
    private double height;

    public Student1() {
    }

    public double getHeight() {
        return height;
    }

    public void setHeight(double height) {
        this.height = height;
    }

    @Override
    public int compareTo(Student1 o) {
        return Integer.compare(this.age,o.age);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Student1(String name, int age, double height) {
        this.name = name;
        this.age = age;
        this.height = height;
    }

    @Override
    public String toString() {
        return "Student1{" +
                "name='" + name + '\'' +
                ", age=" + age +
                ", height=" + height +
                '}';
    }
}